package com.tarena.test.luban.demo.cart;

import com.tarena.demo.luban.all.main.rpc.DubboTest2RpcApi;
import com.tarena.demo.luban.all.main.rpc.DubboTestRpcApi;
import com.tarena.luban.demo.cart.api.DubboTest2Api;
import com.tarena.luban.demo.cart.api.DubboTestApi;
import org.apache.dubbo.config.ProtocolConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.ServiceConfig;
import org.apache.dubbo.config.bootstrap.DubboBootstrap;

import java.util.ArrayList;
import java.util.List;

/**
 * 开启一个dubbo底层 进程
 * 等待接收远程调用
 */
public class Provider2TestRun {
    public static void main(String[] args) {
        ServiceConfig<DubboTest2Api> service2=new ServiceConfig<>();
        service2.setInterface(DubboTest2Api.class);
        service2.setRef(new DubboTest2RpcApi());
        List<ServiceConfig> services=new ArrayList<>();
        services.add(service2);
        //启动dubbo-provider进程
        DubboBootstrap.getInstance()
                //dubbo注册的服务名称
                .application("luban-demo-cart-provider")
                .registry(new RegistryConfig("nacos://localhost:8848"))
                .protocol(new ProtocolConfig("dubbo",20991))
                .service(service2)
                //.services(services)
                .start()
                //一直运行这个provider端进程,直到手动停止
                .await();
    }
}
